package br.com.salao.session;

import javax.ejb.Remote;
import javax.ejb.Stateless;
import javax.ejb.TransactionAttribute;
import javax.ejb.TransactionAttributeType;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;

import org.apache.log4j.Logger;

import br.com.salao.ejb.dao.RatingEstabelecimentoDao;
import br.com.salao.ejb.dao.impl.RatingEstabelecimentoDaoImpl;
import br.com.salao.entity.RatingEstabelecimento;

@Stateless
@Remote(RatingEstabelecimentoBase.class)
public class RatingEstabelecimentoBean implements RatingEstabelecimentoBase {

	/**
	 * @author Dri
	 */
	private static final long serialVersionUID = 1L;
	
	@PersistenceContext(unitName = "SalaoBeleza")
	private EntityManager em;

	private Logger logger = Logger.getLogger(RatingEstabelecimentoBean.class.getName());

	@TransactionAttribute
	public RatingEstabelecimento update(RatingEstabelecimento ratingEstabelecimento) {
		logger.debug(":: RatingEstabelecimentoBean :: update() ::");
		RatingEstabelecimentoDao dao = new RatingEstabelecimentoDaoImpl(em);
		return dao.update(ratingEstabelecimento);
	}

	@TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)
	public RatingEstabelecimento buscarRatingPorId(int idRating) {
		logger.debug(":: RatingEstabelecimentoBean :: buscarRatingPorId() ::");
		RatingEstabelecimentoDao dao = new RatingEstabelecimentoDaoImpl(em);
		return dao.buscarRatingPorId(idRating);
	}
	
	@TransactionAttribute
	public RatingEstabelecimento inserir(RatingEstabelecimento ratingEstabelecimento) {
		logger.debug(":: RatingEstabelecimentoBean :: inserir() ::");
		RatingEstabelecimentoDao dao = new RatingEstabelecimentoDaoImpl(em);
		return dao.inserir(ratingEstabelecimento);
	}

}
